package com.mrjy.schooldiy.controller;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.DiyVideoInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.enums.ResultEnum;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.maintain.dao.ISchoolInfoDao;
import com.mrjy.schooldiy.bo.IDiyVideoBo;

@Controller
@RequestMapping("/schooldiy/video")
public class DiyVideoInfoController {
	@Resource
	private ISchoolInfoDao schoolInfoDao;
	@Resource
	private IDiyVideoBo schoolVideoBo;
	/*
	 * 查询保利威视目录下的资源容量
	 * */
	@RequestMapping("/querySource")
	@ResponseBody
	public Object querySource(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.querySource(dInfo,session);
	}
	/*
	 * 根据id删除保利威视下该目录的视频
	 * */
	@RequestMapping("/deleteSource")
	@ResponseBody
	public Object deleteSource(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.deleteSource(dInfo,session);
	}
	/*
	 * 根据资源的code删除保利威视下该目录的视频
	 * */
	@RequestMapping("/deleteSourceByCode")
	@ResponseBody
	public Object deleteSourceByCode(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.deleteSourceByCode(dInfo,session);
	}
	@RequestMapping("/insertSource")
	@ResponseBody
	public Object insertVideo(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.insertSourse(dInfo,session);
	}
	@RequestMapping("/editeSource")
	@ResponseBody
	public Object editeSource(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.editeSource(dInfo,session);
	}
	
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(DiyVideoInfo dInfo,HttpSession session) {	
		UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		HashMap<String, Object> map = new HashMap<String, Object>();
		if(null == loginUser ){
			map.put("err_msg", ResultEnum.NOT_LOGIN);
			return map;
		}
		if (null == dInfo.getIds()) {
			map.put("err_msg", ResultEnum.PARAM_ERROR);
			return map;
		}
		return schoolVideoBo.txUpdateDisableFlag(dInfo);
    }
	@RequestMapping("/queryPageForPcSource")
	@ResponseBody
	public Object queryPageForPcSource(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.queryPageForPcSource(dInfo,session);
	}
	/*
	 * 微信端分页查询
	 * */
	@RequestMapping("/queryPageList")
	@ResponseBody
	public Object queryPageList(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.queryPageList(dInfo,session);
	}
	
	/*
	 * 微信端根据id查询音视频资源详情
	 * */
	@RequestMapping("/queryAuViSourceById")
	@ResponseBody
	public Object queryAuViSourceById(DiyVideoInfo dInfo,HttpSession session){
		return schoolVideoBo.queryAuViSourceById(dInfo,session);
	}
	/*
	 *微信端视频或音频浏览量+1
	 */
	@RequestMapping("/addAuViViewNum")
	@ResponseBody
	public Object addAuViViewNum(DiyVideoInfo dInfo,HttpSession session) {	
		return schoolVideoBo.addAuViViewNum(dInfo,session);
    }
}
